package com.javaweb.searchengine.app.conf;

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.resource.VersionResourceResolver;
import org.springframework.web.servlet.resource.WebJarsResourceResolver;

//@Configuration
public class LocalMvcConfiguration extends WebMvcConfigurerAdapter {

	/**
	 * 静态资源管理
	 * */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		super.addResourceHandlers(registry);

		registry.addResourceHandler("/webjars")
				.addResourceLocations("classpath:/META-INF/resources/webjars/")
				.setCachePeriod(356 * 24 * 3600).resourceChain(true)
				.addResolver(new WebJarsResourceResolver());

		registry.addResourceHandler("/**")
				.addResourceLocations(
						"classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/")
				.setCachePeriod(356 * 24 * 3600)
				.resourceChain(true)
				.addResolver(
						new VersionResourceResolver()
								.addContentVersionStrategy("/**"));
	}
}
